package sample;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

/**
 * Created by RXJ on 2018/3/10.
 */
public class Solution {
    public static String PrintMinNumber(int [] numbers) {
        String result = "";
        int length=numbers.length;
        if(length<1){
            return result;
        }
        ArrayList<Integer> list=new ArrayList<Integer>();
        for(int i=0;i<length;i++){
            list.add(numbers[i]);
        }
        Collections.sort(list,new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                System.out.print(""+o1+"    "+o2+"   ");
                String result1=o1+""+o2;
                String result2=o2+""+o1;
                System.out.println(result1.compareTo(result2));
                return result1.compareTo(result2);
            }
        });
        Iterator<Integer> iterator=list.iterator();
        while(iterator.hasNext()){
            result+=(iterator.next()+"");
            System.out.println(result);
        }
        return result;
    }

    public static void main(String[]  args){
        int[] nums = {32,321,3};
        System.out.println( Solution.PrintMinNumber(nums));
    }
}
